<?php
namespace app\admin\model;
use think\Model;

class Brand extends Model
{
    //搜索器
    public function searchKeywordsAttr($q,$v)
    {
        $q->where('brand_name','like',"%{$v}%");
    }

    public function searchIfShowAttr($q,$v)
    {
        $q->where('if_show','in',$v);
    }
    public function searchRecommendedAttr($q,$v)
    {
        $q->where('recommended','=',$v);
    }
    public function searchWtuAttr($q)
    {
        $q->where(function ($q) {
            $q->whereOr('brand_logo', '=', '')
                ->whereOr('brand_logo', null);

        });
    }
        public function searchTuAttr($q,$v)
    {
      $q->where('brand_logo','<>','');
    }

    public  static function getBrandList($where)
    {
        $list = Brand::withSearch(array_keys($where),$where)->paginate([
            'list_rows'=>5,
            'query'=>$where
        ]);
        return $list;
    }
}